﻿/*
   Author: Tomer Paz
   games.com
   2009
*/

/* Right Panel container (Viewer) */

package monopoly.views {
	import flash.display.Sprite;
	import flash.display.DisplayObjectContainer;
	import flash.display.DisplayObject;
	import fl.containers.ScrollPane;
	import flash.display.Stage;
	import monopoly.IFS.GLOBALS;
	

	public class VPanel extends ScrollPane
		{
		public static const RPANEL_UPPER:String		= "RPanelUpperObject";
		public static const RPANEL_MIDDLE:String	= "RPanelMiddleObject";
		public static const RPANEL_LOWER:String		= "RPanelLowerObject";
		public static const RPANEL_BOTTOM:String	= "RPanelBottomObject";

		protected var _rootSprite:Sprite;
		
		public function VPanel(rootSprite:Sprite)
			{
			_rootSprite = rootSprite;
			
			with (this)
				{
				width	= GLOBALS.VPANEL_WIDTH; //_rootSprite.width  * 0.28;
				height  = GLOBALS.VPANEL_HEIGHT; //_rootSprite.height * 1;
				x		= _rootSprite.root.stage.x;// + _rootSprite.width;
				y		= _rootSprite.y;
				alpha	= 0.9;
				setSize(width, height);
				opaqueBackground = GLOBALS.DEFAULT_BG_COLOR;
				}
			_rootSprite.addChild(this);
			}
		public override function addChild(object:DisplayObject):DisplayObject
			{
			if (RPANEL_UPPER == object.name)
				{
				object.x	  = 1;
				object.y	  = 1;
				object.width  = this.width;			
				}
			else if (RPANEL_MIDDLE == object.name)
				{
				object.x	 = 1;
				object.y	 = 1+ this.height * 0.4;
				if (GLOBALS.DEBUG & GLOBALS.DEBUG_VIEW)
					trace("[VPanel][addChild][MIDDLE] my width was: " + this.width);
				object.width = this.width as Number;
				if (GLOBALS.DEBUG & GLOBALS.DEBUG_VIEW)
					trace("[VPanel][addChild][MIDDLE] my Object width now is: " + object.width);
				}
			else if (RPANEL_LOWER == object.name)
				{
				object.x	 = 1;
				object.y	 = 1 + this.height * 0.7;
				object.width = this.width;
				}
			else if (RPANEL_BOTTOM == object.name)
				{
				object.x	 = 1;
				object.y	 = 1 + this.height * 0.9;
				object.width = this.width;
				}
			super.addChild(object);
			return object;
			}
		public override function removeChild(object:DisplayObject):DisplayObject
			{
			super.removeChild(object);
			return object;
			}
		}
}
